#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;

class Date {
	int year;
	int month;
	int day;

	friend ostream& operator<<(ostream& out, const Date& d);
	

	friend class Date_;
public:
	int GetMonthDay()
	{
		int a[13] = { 0 ,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (month == 2 && (year % 4 == 0 && year % 100 != 0 || year % 400 == 0))
		{
			return 29;
		}
		return a[month];
	}

	Date(int y = 2000, int m = 2, int d = 29)
		:year(y)
		, month(m)
		, day(d)
	{

	}
	string toText()const
	{
		string s(to_string(year));
		s = s + '-' + to_string(month) + '-' + to_string(day);
		return s;
	}

	Date& operator+=(int gap)
	{
		day += gap;

		while (day > GetMonthDay())
		{
			day -= GetMonthDay();
			month++;
			if (month > 12)
			{
				year++;
				month = 1;
			}
		}

		return *this;
	}

	Date operator+(int gap)
	{
		Date newd(*this);
		newd += gap;
		return newd;
	}

	Date operator++()
	{
		return Date(*this += 1);
	}

	bool operator>(const Date& d)
	{
		if (year > d.year)
		{
			return true;
		}
		else if(year == d.year)
		{
			if (month > d.month)
			{
				return true;
			}
			else if (month == d.month)
			{
				if (day > d.day)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
};

Date operator+(int gap , const Date& d)
{
	Date newd(d);
	newd += gap;
	return newd;
}

ostream& operator<<(ostream& out, const Date& d)
{
	cout << d.toText();
	return out;
}


class Date_ {
	int year = 1999;
	int month = 1;
	int day = 1;

	friend ostream& operator<<(ostream& out, const Date_& d);
public:
	Date_& operator=(Date d)
	{
		year = d.year;
		month = d.month;
		day = d.day;
		return *this;
	}
};

ostream& operator<<(ostream& out, const Date_& d)
{
	cout << d.year<<'-'<<d.month<<'-'<<d.day;
	return out;
}


int main()
{
	//Date d1(2024,2,28);
	//
	//cout << d1 << ' ' ;
	//Date d2 = 1 + d1 ;
	//cout << d2<<' ';

	//cout << (d2 > d1) <<' ' << (d1 > d2);


	Date d1(2024, 5, 17);
	Date_ d2;
	d2 = d1;
	cout << d2;
	return 0;
}



class Complex {
	double real = 0;
	double imag = 0;

	friend Complex add(const Complex c1, const Complex c2);
	friend istream& operator>>(istream& i, Complex& c);
	friend ostream& operator<<(ostream& out, const Complex& c);
public:
	Complex(double r = 0, double i = 0) :real(r), imag(i)
	{

	}
	void print()
	{
		cout << real;
		if (imag > 0)
		{
			cout << '+';
		}
		cout << imag << 'i'<<endl;
	}

};

Complex add(const Complex c1, const Complex c2)
{
	return Complex(c1.real + c2.real, c1.imag + c2.imag);
}

istream& operator>>(istream& in, Complex& c)
{
	cin >> c.real >> c.imag;
	return in;
}

ostream& operator<<(ostream& out, const Complex& c)
{
	cout << c.real;
	if(c.imag>0)
	{ 
		cout<< '+';
	}
	cout<< c.imag<<'i';
	return out;
}


//int main1_1()
//{
//	int a, b, c, d;
//	cin >> a >> b >> c >> d;
//	Complex c1(a,b), c2(c,d);
//
//
//	c1.print();
//	c2.print();
//
//	add(c1, c2).print();
//
//	return 0;
//}

int main1()
{
	Complex c1, c2;
	cin >> c1 >> c2;

	cout << c1 << endl;
	cout << c2 << endl;
	cout << add(c1, c2);
	
	return 0;
}